$(document).ready(function(){
    if (links_lists.links_id == "") {
        // 新建外链
        $("#links_lists_add_row").show();
        $("#publish_button_add").show();
        $("#publish_button_update").hide();
    } else {
        // 更新外链
        $("#links_lists_add_row").hide();
        $("#publish_button_add").hide();
        $("#publish_button_update").show();
        $("#platfrom_typeul_10").hide();
        $("#platfrom_typeul_11").hide();
        $("#platfrom_typeul_12").hide();
    }
    renderLinks();

    $("#platfrom_typeul li").click(function(){
        var platfrom = $(this).attr('platfrom');
        links_lists.platfrom = platfrom;
        if (platfrom == 1) {
            links_lists.platfrom_type = 12;
        } else if (platfrom == 2) {
            links_lists.platfrom_type = 4;
        } else if (platfrom == 3) {
            links_lists.platfrom_type = 8;
        } else if (platfrom == 4) {
            links_lists.platfrom_type = 8;
        } else if (platfrom == 5) {
            links_lists.platfrom_type = 9;
        } else if (platfrom == 6) {
            links_lists.platfrom_type = 4;
        } else if (platfrom == 7) {
            links_lists.platfrom_type = 1;
        } else if (platfrom == 8) {
            links_lists.platfrom_type = 7;
        } else if (platfrom == 9) {
            links_lists.platfrom_type = 10;
        } else if ([10,11,12].includes(platfrom)) {
            links_lists.platfrom_type = 20;
        } else if (platfrom == 13) {
            links_lists.platfrom_type = 13;
        } else {
            links_lists.platfrom_type = 1;
        }
        renderLinks();
    });

    $("#qrcode_switch_type li").click(function(){
        var qrcode_switch_type = $(this).attr('data');
        links_lists.qrcode_switch_type = qrcode_switch_type;
        switchTypeRender();
    })

    $("#qrcode_switch_lists li").click(function(){
        var qrcode_switch = $(this).attr('data');
        links_lists.qrcode_switch = qrcode_switch;
        qrcodeSwitchRender();
    })

    $("#work_time_lists li").click(function(){
        var work_time = $(this).attr('data');
        links_lists.work_time = work_time;
        workTimeRender();
    });

    $("#qrcode_upper_lists li").click(function(){
        var qrcode_upper = $(this).attr('data');
        links_lists.qrcode_upper = qrcode_upper;
        qrcodUpperRender();
    });

    $("#device_bind_lists li").click(function(){
        var device_bind = $(this).attr('data');
        links_lists.device_bind = device_bind;
        deviceBindRender();
    });

    $("#miniapp_style_ul li").click(function(){
        var miniapp_style = $(this).attr('data');
        links_lists.miniapp_style = miniapp_style;
        miniappStyleRender(2);
    });

    $("#platfrom_child li").click(function(){
        var platfrom_child_id = $(this).attr('id');
        links_lists.platfrom_type = platfrom_child_id.replace('platfrom_child', '');
        renderLinks();
    });

    addTopNotice("status");
});

function renderLinks() {
    $("#title").val(links_lists.title);
    platfromTypeChange(links_lists.platfrom);
    platfromChildChange(links_lists.platfrom_type);
    newsHelp();
    renderQrcodes();
    showMiniapp();
    switchTypeRender();
    qrcodeSwitchRender();
    workTimeRender();
    qrcodUpperRender();
    deviceBindRender();
    miniappStyleRender(1);
    $(".mview-load-page").hide();
}

function switchTypeRender() {
    if ($.inArray(links_lists.platfrom_type, [1,2,3,4,5,6,7,10,13]) != -1) {
        $("#qrcodes_setting").hide();
        return;
    }
    $("#qrcode_switch_type li").removeClass("active");
    $("#qrcode_switch_type li[data="+links_lists.qrcode_switch_type+"]").addClass("active");
    if (links_lists.qrcode_switch_type == "default") {
        $("#qrcodes_setting").hide();
    } else {
        $("#qrcodes_setting").show();
    }
}

function qrcodeSwitchRender() {
    $("#qrcode_switch_lists li").removeClass("active");
    $("#qrcode_switch_lists li[data="+links_lists.qrcode_switch+"]").addClass("active");
}

function workTimeRender() {
    $("#work_time_lists li").removeClass("active");
    $("#work_time_lists li[data="+links_lists.work_time+"]").addClass("active");
}

function qrcodUpperRender() {
    $("#qrcode_upper_lists li").removeClass("active");
    $("#qrcode_upper_lists li[data="+links_lists.qrcode_upper+"]").addClass("active");
    if (links_lists.qrcode_upper == 2) {
        $("#qrcode_daily_row").show();
    } else {
        $("#qrcode_daily_row").hide();
    }
}

function deviceBindRender() {
    $("#device_bind_lists li").removeClass("active");
    $("#device_bind_lists li[data="+links_lists.device_bind+"]").addClass("active");
}

function miniappStyleRender(step) {
    $("#miniapp_style_ul li").removeClass("active");
    $("#miniapp_style_ul li[data="+links_lists.miniapp_style+"]").addClass("active");
    if (links_lists.miniapp_style == 1) {
        $("#qrcode_setting").show();
        $("#qrcode_notice_row").show();
    } else {
        $("#qrcode_setting").hide();
        $("#qrcode_notice_row").hide();
    }
    if (step == 2) {
        phonePreview();
    }
}

function platfromTypeChange(platfrom) {
    $('#platfrom_typeul li').removeClass('active');
    $('#platfrom_typeul_'+platfrom).addClass('active');
    $("#all-form").show();
    $("#jump-form").hide();
    platfrom = platfrom.toString();
    if (['3','4','5','8','9','10','11','12','13'].includes(platfrom)) {
        $("#platfrom_child").hide();
    } else {
        $("#platfrom_child").show();
        $('#platfrom_child li').hide();
        $('#platfrom_child li').removeClass('active');
    }
    if (platfrom == "1") {
        $("#platfrom_child1").show();
        $("#platfrom_child12").show();
    } else if(platfrom == "2" || platfrom == "6"){
        $("#platfrom_child4").show();
        $("#platfrom_child6").show();
        $("#platfrom_child11").show();
    } else if(platfrom == "7"){
        $("#platfrom_child1").show();
        $("#platfrom_child14").show();
        $("#platfrom_child15").show();
        $("#platfrom_child16").show();
    } else if(platfrom == "5"){
        // $("#platfrom_child3").show();
        $("#platfrom_child9").show();
        $("#platfrom_child13").show();
    } else if(['10','11','12'].includes(platfrom)){
        $("#all-form").hide();
        $("#jump-form").show();
        $("#jumpurlwk").hide();
        $("#jumpurlsxb").hide();
        $("#jumpurlhkzs").hide();
        if(platfrom == "10"){
            $("#jumpurlwk").show();
        }else if(platfrom == "11"){
            $("#jumpurlsxb").show();
        }else if(platfrom == "12"){
            $("#jumpurlhkzs").show();
        }
    } else {
        // $("#platfrom_child3").show();
        $("#platfrom_child8").show();
        $("#platfrom_child13").show();
    }
}

function platfromChildChange(platfrom_child_id) {
    $('#platfrom_child li').removeClass('active');
    $('#platfrom_child'+platfrom_child_id).addClass('active');
    if (platfrom_child_id == 1) {
        changePlatfromType(1);
    } else if(platfrom_child_id == 3 || platfrom_child_id == 2){
        changePlatfromType(3);
    } else if(platfrom_child_id == 4){
        changePlatfromType(4);
    } else if(platfrom_child_id == 5){
        changePlatfromType(5);
    } else if(platfrom_child_id == 6){
        changePlatfromType(6);
    } else if(platfrom_child_id == 7){
        changePlatfromType(7);
    } else if(platfrom_child_id == 8){
        changePlatfromType(8);
    } else if(platfrom_child_id == 9){
        changePlatfromType(9);
    } else if(platfrom_child_id == 10){
        changePlatfromType(10);
    } else if(platfrom_child_id == 11){
        changePlatfromType(11);
    }else if(platfrom_child_id == 12){
        changePlatfromType(12);
    } else if(platfrom_child_id == 13){
        changePlatfromType(13);
    } else if(platfrom_child_id == 14){
        changePlatfromType(14);
    } else if(platfrom_child_id == 15){
        changePlatfromType(15);
    } else if(platfrom_child_id == 16){
        changePlatfromType(16);
    } else {
        changePlatfromType(1);
    }
}

function newsHelp() {
    if (links_lists.platfrom == 1) {
        if (links_lists.platfrom_type == 12) {
            $("#newshelp").html("将个人微信/企业微信/微信群二维码上传即可；点击查看");
        } else {
            $("#newshelp").html("写一篇公众号文章,将公众号卡片/二维码放在文章中；点击查看");
        }
    } else if (links_lists.platfrom == 2) {
        if (links_lists.platfrom_type == 4) {
            $("#newshelp").html("企业小程序使用本模式请先添加小程序；点击查看");
        } else if (links_lists.platfrom_type == 11) {
            $("#newshelp").html("将小程序的小程序码上传即可；点击查看");
        } else {
            $("#newshelp").html("个人资质/其他机构开发的小程序(如微店,微信直播等)；点击查看");
        }
    } else if (links_lists.platfrom == 3) {
        if (links_lists.platfrom_type == 3) {
            $("#newshelp").html("点击小程序客服,客服自动推送个人微信二维码和链接给客户；点击查看");
        } else {
            $("#newshelp").html("将个人微信二维码上传；点击查看");
        }
    } else if (links_lists.platfrom == 4) {
        if (links_lists.platfrom_type == 3) {
            $("#newshelp").html("点击小程序客服,客服自动推送企微二维码和链接；点击查看");
        } else {
            $("#newshelp").html("将企业微信二维码上传；点击查看");
        }
    } else if (links_lists.platfrom == 5) {
        if (links_lists.platfrom_type == 3) {
            $("#newshelp").html("点击小程序客服,客服自动推送群二维码和链接；点击查看");
        } else {
            $("#newshelp").html("将微信群二维码上传，点击");
        }
    } else if (links_lists.platfrom == 6) {
        if (links_lists.platfrom_type == 4) {
            $("#newshelp").html("微信小商店其实就是微信小程序；点击查看");
        } else if (links_lists.platfrom_type == 11) {
            $("#newshelp").html("将小程序的小程序码上传即可；点击查看");
        } else {
            $("#newshelp").html("其他机构的小商店；点击查看");
        }
    } else if (links_lists.platfrom == 7) {
        $("#newshelp").html("写一篇公众号文章,将视频号卡片/视频放在文章中即可；点击查看");
    } else if (links_lists.platfrom == 8) {
        $("#newshelp").html("先自动复制公众号/小程序,然后打开微信；点击查看");
    } else if (links_lists.platfrom == 9) {
        $("#newshelp").html("打开百度/QQ/UC浏览器APP,自动分享朋友圈；点击查看");
    }

    $("#notices1").hide();
    $("#notices4").hide();
    $("#notices6").hide();
    $("#notices9").hide();
    $("#notices13").hide();

    if (links_lists.platfrom_type == 1) {
        $("#notices1").show();
    } else if (links_lists.platfrom_type == 4) {
        $("#notices4").show();
    } else if (links_lists.platfrom_type == 6) {
        $("#notices6").show();
    } else if (links_lists.platfrom == 4 || links_lists.platfrom == 5) {
        $("#notices9").show();
    } else if (links_lists.platfrom_type == 13) {
        $("#notices13").show();
    }
}

function jumpurl(url) {
    window.open(url);
}

function showqrcode(id) {
    $("#"+id).show();
}

function showDemo() {
    if (links_lists.platfrom_type == 1) {
        if (links_lists.platfrom == 1) {
            showDemoQrcode("https://res.wailian1.cn/wepage/20230412-121448-532.png","公众号文章演示");
        } else if(links_lists.platfrom == 7){
            showDemoQrcode("https://res.wailian1.cn/wepage/20230412-121751-530.png","视频号文章演示");
        } else {
            showDemoQrcode("https://res.wailian1.cn/wepage/20230412-121911-378.png","公众号二维码演示");
        }
    } else if(links_lists.platfrom_type == 2 || links_lists.platfrom_type == 3){
        $("#imgdemo").attr("src","https://res.wailian1.cn/miniapp/images/gif/2.gif");
        $('#myModal').modal('toggle')
    } else if(links_lists.platfrom_type == 4 || links_lists.platfrom_type == 5){
        if (links_lists.platfrom == 2) {
            showDemoQrcode("https://res.wailian1.cn/wepage/20230412-122025-699.png","跳转小程序演示");
        } else {
            showDemoQrcode("https://res.wailian1.cn/wepage/20230412-122158-787.png","跳转微信小商店演示");
        }
    } else if(links_lists.platfrom_type == 6){
        showDemoQrcode("https://res.wailian1.cn/wepage/20230412-122303-593.png","跳转三方小程序演示");
    } else if(links_lists.platfrom_type == 7){
        $("#imgdemo").attr("src","https://res.wailian1.cn/miniapp/images/gif/7.gif");
        $('#myModal').modal('toggle')
    } else if(links_lists.platfrom_type == 10){
        $("#imgdemo").attr("src","https://res.wailian1.cn/miniapp/images/gif/11.gif");
        $('#myModal').modal('toggle')
    } else if(links_lists.platfrom_type == 8){
        if (links_lists.platfrom == 3) {
            showDemoQrcode("https://res.wailian1.cn/wepage/20230412-122843-873.png","跳转个人二维码演示");
        } else {
            showDemoQrcode("https://res.wailian1.cn/wepage/20230412-122748-544.png","跳转企微二维码演示");
        }
    } else if(links_lists.platfrom_type == 9){
        showDemoQrcode("https://res.wailian1.cn/wepage/20230412-122748-544.png","跳转企微二维码演示");
    } else if(links_lists.platfrom_type == 11){
        showDemoQrcode("https://res.wailian1.cn/wepage/20230412-122638-890.png","小程序码演示");
    } else if(links_lists.platfrom_type == 12){
        showDemoQrcode("https://res.wailian1.cn/wepage/20230412-121911-378.png","公众号二维码演示");
    }else if([14,15,16].includes(links_lists.platfrom_type)){
        showDemoQrcode("https://res.wailian1.cn/wepage/20230412-122748-555.png","跳转视频号演示");
    } else {
        showDemoQrcode("https://res.wailian1.cn/wepage/20230412-122748-544.png","跳转企微二维码演示");
    }
}

function showDemoQrcode(url,name) {
    $("#service_qrcode").attr("src",url);
    $("#service_text").text(name);
    $("#service_time").text("请使用微信扫描查看案例");
    $("#service_describe").text("案例仅展示基础内容,您可以根据您的业务自定义外链内容。");
    $('#serviceModal').modal('toggle');
}

function showMsg() {
    var htmls = "";
    var nike = $("#nike").val();
    $("#msgcontent").hide();
    $("#miniapp_setting_row").hide().html("");
    if (links_lists.platfrom_type == 7) {
        $("#msgContentTitle").text("复制搜索微信配置:").show();
        htmls = '<label><b>*</b>微信头像:</label><div class="col-md-6 file-cotainer"><a href="javascript:;" class="file-border"><font>修改图片</font><input type="file" id="upload_msg_logo" accept="image/*" onchange="jsUpload(\'msg_logo\',100)"></a><img src="https://ttwls.oss-cn-beijing.aliyuncs.com/assets/images/template/wechat_logo.png" class="file-border-view" id="msg_logo_show"><input type="hidden" class="m-input" id="msg_logo" onchange="phoneInputEdit(this);" value="https://ttwls.oss-cn-beijing.aliyuncs.com/assets/images/template/wechat_logo.png"></div><div class="m-col-5 m-xs-12"><label><b>*</b>微信号:</label><input type="text" maxlength="35" class="m-input" id="wechat" onchange="phoneInputEdit(this)" placeholder="请输入复制的微信号/微信名称" value=""></div><div class="m-col-3 m-xs-12"><label><b>*</b>微信昵称:</label><input type="text" maxlength="30" class="m-input" id="msg_nike" onchange="phoneInputEdit(this);" placeholder="请输入微信昵称" value=""></div>';
    } else if (links_lists.platfrom_type == 10) {
        $("#msgContentTitle").text("朋友圈展示样式:").show();
        htmls = '<label><b>*</b>微信头像:</label><input type="hidden" class="m-input" id="msg_logo" onchange="phoneInputEdit(this);"  value="https://ttwls.oss-cn-beijing.aliyuncs.com/assets/images/template/wechat_logo.png"><div class="col-md-6 file-cotainer"><a href="javascript:;" class="file-border"><font>修改图片</font><input type="file" id="upload_msg_logo" accept="image/*" onchange="jsUpload(\'msg_logo\',100)"></a><img src="https://ttwls.oss-cn-beijing.aliyuncs.com/assets/images/template/wechat_logo.png" class="file-border-view" id="msg_logo_show"></div><div class="m-col-5 m-xs-12"><label><b>*</b>微信号:</label><input type="text" maxlength="35" class="m-input" id="wechat" onchange="phoneInputEdit(this)" placeholder="请输入微信号,朋友圈不能用时降级为复制搜索！" value=""></div><div class="m-col-3 m-xs-12"><label><b>*</b>微信昵称:</label><input type="text" maxlength="30" class="m-input" id="msg_nike" onchange="phoneInputEdit(this);" placeholder="请输入微信昵称,朋友圈不能用时降级为复制搜索！" value=""></div><label><b>*</b>朋友圈提示:</label><input type="text" maxlength="30" class="m-input" id="msg_describe" onchange="phoneInputEdit(this)" placeholder="请输入朋友圈提示,如(不用分享,点击关注我们～)" value=""><label><b>*</b>朋友圈链接:</label><input type="text" class="m-input" id="msg_url" onchange="phoneInputEdit(this)" placeholder="点击朋友圈链接跳转的网址" value="">';
     } else if (links_lists.platfrom_type == 8) {
        $("#msgContentTitle").hide();
        htmls = '<div id="qrcode_setting"><label><b>*</b>微信头像:</label><input type="hidden" class="m-input" id="msg_logo" onchange="phoneInputEdit(this);"  value="https://ttwls.oss-cn-beijing.aliyuncs.com/assets/images/template/wechat_logo.png"><div class="col-md-6 file-cotainer"><a href="javascript:;" class="file-border"><font>修改图片</font><input type="file" accept="image/*" id="upload_msg_logo" onchange="jsUpload(\'msg_logo\',100)"></a><img src="https://ttwls.oss-cn-beijing.aliyuncs.com/assets/images/template/wechat_logo.png" class="file-border-view" id="msg_logo_show"></div><div class="m-col-3 m-xs-12"><label><b>*</b>微信昵称:</label><input type="text" maxlength="30" class="m-input" id="msg_nike" onchange="phoneInputEdit(this);" onchange="phoneInputEdit(this);" placeholder="请输入微信昵称" value=""></div><label><b>*</b>微信描述:</label><input type="text" maxlength="30" class="m-input" id="msg_describe" onchange="phoneInputEdit(this);" placeholder="请输入微信描述(如:加李老师免费领取课程)" value=""></div><label><b>*</b>上传二维码:<i class="bx bxs-help-circle" id="tooltip_wechat1" data-toggle="tooltip" data-placement="right" title="配合上方二维码切换方式可实现活码功能，最多支持200张二维码。"></i><font>详情里支持批量上传二维码</font></label><input type="hidden" class="m-input" id="msg_qrcodes" value=""><div class="col-md-12 file-cotainer" style="margin-top:0"><a href="javascript:;" class="file-border"><font id="upload_msg_qrcodes_text">添加图片</font><input type="file" accept="image/*" id="upload_msg_qrcodes" onchange="jsQrcodeUpload(\'msg_qrcodes\',300)"></a><div id="msg_qrcodes_lists" style="width:80%;"></div></div><div id="qrcode_notice_row" class="m-col-4 m-xs-12"><label>底部操作提示:</label><input type="text" maxlength="30" class="m-input" id="qrcode_notice" onchange="phoneInputEdit(this);" placeholder="请输入底部操作引导提示" value="长按3秒识别二维码"></div>';
     } else if (links_lists.platfrom_type == 9) {
        $("#msgContentTitle").hide();
        htmls = '<div id="qrcode_setting"><label><b>*</b>微信头像:</label><input type="hidden" class="m-input" id="msg_logo" onchange="phoneInputEdit(this);"  value="https://ttwls.oss-cn-beijing.aliyuncs.com/assets/images/template/wechat_logo.png"><div class="col-md-6 file-cotainer"><a href="javascript:;" class="file-border"><font>修改图片</font><input type="file" accept="image/*" id="upload_msg_logo" onchange="jsUpload(\'msg_logo\',100)"></a><img src="https://ttwls.oss-cn-beijing.aliyuncs.com/assets/images/template/wechat_logo.png" class="file-border-view" id="msg_logo_show"></div><div class="m-col-3 m-xs-12"><label><b>*</b>微信群名称:</label><input type="text" maxlength="30" class="m-input" id="msg_nike" onchange="phoneInputEdit(this);" onchange="phoneInputEdit(this);" placeholder="请输入群名称" value=""></div><label><b>*</b>微信描述:</label><input type="text" maxlength="30" class="m-input" id="msg_describe" onchange="phoneInputEdit(this);" placeholder="请输入微信群描述(如:已有500人加入)" value=""></div><label><b>*</b>上传二维码:<i class="bx bxs-help-circle" id="tooltip_wechat1" data-toggle="tooltip" data-placement="right" title="配合上方二维码切换方式可实现活码功能，最多支持200张二维码。"></i><font>详情里支持批量上传二维码</font></label><input type="hidden" class="m-input" id="msg_qrcodes" value=""><div class="col-md-12 file-cotainer" style="margin-top:0"><a href="javascript:;" class="file-border"><font id="upload_msg_qrcodes_text">添加图片</font><input type="file" id="upload_msg_qrcodes" accept="image/*" onchange="jsQrcodeUpload(\'msg_qrcodes\',300)"></a><div id="msg_qrcodes_lists" style="width:80%;"></div></div><div id="qrcode_notice_row" class="m-col-4 m-xs-12"><label>底部操作提示:</label><input type="text" maxlength="30" class="m-input" id="qrcode_notice" onchange="phoneInputEdit(this);" placeholder="请输入底部操作引导提示" value="长按3秒识别二维码"></div>';
    } else if (links_lists.platfrom_type == 11) {
        $("#msgContentTitle").hide();
        htmls = '<div id="qrcode_setting"><label>小程序头像:</label><input type="hidden" class="m-input" id="msg_logo" onchange="phoneInputEdit(this);" value="https://ttwls.oss-cn-beijing.aliyuncs.com/assets/images/template/wechat_logo.png"><div class="col-md-6 file-cotainer"><a href="javascript:;" class="file-border"><font>修改图片</font><input type="file" accept="image/*" id="upload_msg_logo" onchange="jsUpload(\'msg_logo\',100)"></a><img src="https://ttwls.oss-cn-beijing.aliyuncs.com/assets/images/template/wechat_logo.png" class="file-border-view" id="msg_logo_show"></div><label>小程序名称:</label><input type="text" maxlength="30" class="m-input" id="msg_nike" onchange="phoneInputEdit(this);" onchange="phoneInputEdit(this);" placeholder="请输入小程序名称" value=""><label>小程序描述:</label><input type="text" maxlength="30" class="m-input" id="msg_describe" onchange="phoneInputEdit(this);" placeholder="请输入小程序描述(如:长按领取福利)" value=""></div><label>小程序码:</label><input type="hidden" class="m-input" id="msg_qrcodes" value=""><div class="col-md-12 file-cotainer" style="margin-top:0"><a href="javascript:;" class="file-border"><font id="upload_msg_qrcodes_text">添加图片</font><input type="file" accept="image/*" id="upload_msg_qrcodes" onchange="jsQrcodeUpload(\'msg_qrcodes\',300)"></a><div id="msg_qrcodes_lists" style="width:80%;"></div></div><div id="qrcode_notice_row" class="m-col-4 m-xs-12"><label>底部操作提示:</label><input type="text" maxlength="30" class="m-input" id="qrcode_notice" onchange="phoneInputEdit(this);" placeholder="请输入底部操作引导提示" value="长按3秒识别小程序码"></div>';
    } else if (links_lists.platfrom_type == 12) {
        $("#msgContentTitle").hide();
        htmls = '<div id="qrcode_setting"><label>公众号头像:</label><input type="hidden" class="m-input" id="msg_logo" onchange="phoneInputEdit(this);" value="https://ttwls.oss-cn-beijing.aliyuncs.com/assets/images/template/wechat_logo.png"><div class="col-md-6 file-cotainer"><a href="javascript:;" class="file-border"><font>修改图片</font><input type="file" accept="image/*" id="upload_msg_logo" onchange="jsUpload(\'msg_logo\',100)"></a><img src="https://ttwls.oss-cn-beijing.aliyuncs.com/assets/images/template/wechat_logo.png" class="file-border-view" id="msg_logo_show"></div><label><b>*</b>公众号名称:</label><input type="text" maxlength="30" class="m-input" id="msg_nike" onchange="phoneInputEdit(this);" onchange="phoneInputEdit(this);" placeholder="请输入公众号名称" value=""><label><b>*</b>公众号描述:</label><input type="text" maxlength="30" class="m-input" id="msg_describe" onchange="phoneInputEdit(this);" placeholder="请输入公众号描述(如:已有500人加入)" value=""></div><label><b>*</b>公众号二维码:</label><input type="hidden" class="m-input" id="msg_qrcodes" value=""><div class="col-md-12 file-cotainer" style="margin-top:0"><a href="javascript:;" class="file-border"><font id="upload_msg_qrcodes_text">添加图片</font><input type="file" accept="image/*" id="upload_msg_qrcodes" onchange="jsQrcodeUpload(\'msg_qrcodes\',300)"></a><div id="msg_qrcodes_lists" style="width:80%;"></div></div><div id="qrcode_notice_row" class="m-col-4 m-xs-12"><label>底部操作提示:</label><input type="text" maxlength="30" class="m-input" id="qrcode_notice" onchange="phoneInputEdit(this);" placeholder="请输入底部操作引导提示" value="长按3秒识别二维码"></div>';
    }else if (links_lists.platfrom_type == 4) {
        $("#msgContentTitle").text("跳转小程序配置:").show();
        htmls = '<label>小程序路径：<i class="bx bxs-help-circle" data-toggle="tooltip" data-placement="right" title="点击查看如何获取小程序路径" onclick="gotoArticle(64);"></i></label><input type="text" maxlength="1024" class="m-input" placeholder="请输入小程序路径,为空则跳首页！" value="" id="msg_path" onchange="phoneInputEdit(this)">';
    } else if (links_lists.platfrom_type == 5) {
        htmls = '<label>本模式已被微信废弃，无法继续使用！请使用小程序密钥版！</label>';
    } else if (links_lists.platfrom_type == 6) {
        $("#msgContentTitle").text("跳转到的小程序配置:").show();
        $("#miniapp_setting_row").show().html('<label>小程序引导/宣传页：<i class="bx bxs-help-circle" id="title-icon" data-toggle="tooltip" data-placement="right" title="小程序中转页面的样式配置,创建完成之后可更改"></i></label><div class="links-lists-config"><label>引导页-欢迎图片:</label><input type="hidden" class="m-input" id="msg_logo" value="https://res.wailian1.cn/miniapp/miniapp_default.jpg" onchange="phoneInputEdit(this);"><div class="col-md-6 file-cotainer"><a href="javascript:;" class="file-border"><font>修改图片</font><input type="file" accept="image/*" id="upload_msg_logo" onchange="jsUpload(\'msg_logo\',200)"></a><img src="https://res.wailian1.cn/miniapp/miniapp_default.jpg" class="file-border-view" id="msg_logo_show"></div><div class="m-form-item"><label>引导页-是否显示按钮:</label><div class="m-col-3 m-xs-12"><select class="m-select" id="button_show" style="margin-right: 15px;" onchange="phoneInputEdit(this);"><option value="1" selected>显示</option><option value="2">不显示</option></select></div></div><div id="button_text_row" class="m-form-item"><label>引导页-按钮内容:</label><div class="m-col-3 m-xs-12"><input type="text" maxlength="15" class="m-input" id="button_text" placeholder="请输入按钮内容" value="" onchange="phoneInputEdit(this);" style="margin-bottom:15px;"></div></div></div>');
        htmls = '<label>小程序路径：<i class="bx bxs-help-circle" data-toggle="tooltip" data-placement="right" title="点击查看如何获取小程序路径" onclick="gotoArticle(64);"></i></label><input type="text" maxlength="1024" class="m-input" id="msg_path" placeholder="请输入小程序路径,为空则跳首页！" value="" onchange="phoneInputEdit(this)"><label>小程序APPID：<i class="bx bxs-help-circle" data-toggle="tooltip" data-placement="right" title="点击查看如何获取小程序APPID" onclick="gotoArticle(40);"></i></label><input type="text" class="m-input" id="msg_appid" placeholder="请输入小程序APPID" maxlength="18" value="" onchange="phoneInputEdit(this)"><label>小程序原始ID：<i class="bx bxs-help-circle" data-toggle="tooltip" data-placement="right" title="点击查看如何获取小程序原始ID" onclick="gotoArticle(40);"></i></label><input type="text" maxlength="15" class="m-input" id="msg_original_id" placeholder="请输入小程序原始ID" value="" onchange="phoneInputEdit(this)">';
    } else if (links_lists.platfrom_type == 2 || links_lists.platfrom_type == 3) {
        htmls = '<label>本模式已废弃，请使用 摩尔微客 来实现！</label>';
    } else if (links_lists.platfrom_type == 13) {
        $("#msgContentTitle").text("跳转网页配置:").show();
        htmls = '<label><b>*</b>请输入H5链接:<i class="bx bxs-help-circle" id="tooltip_wechat3" data-toggle="tooltip" data-placement="right" title="跳转H5链接必须上架独家小程序,并且H5链接不支持微信支付。"></i></label><input type="text" class="m-input" id="msg_url" placeholder="请输入H5链接网址" value="" onchange="phoneInputEdit(this)">';
    } else if (links_lists.platfrom_type == 14) {
        $("#msgContentTitle").text("视频号主页参数配置:").show();
        htmls = '<div class="m-form-item"><label><b>*</b>视频号ID:<font>点击查看<a href="/admin/documents/documents_detail/75" target="_blank" class="text-primary">获取教程</a></font></label><div class="m-col-3 m-xs-12"><input type="text" class="m-input" id="sph_id" placeholder="请输入视频号ID" value="" onchange="phoneInputEdit(this)" maxlength="15"></div></div><label>小程序引导页:</label><input type="hidden" class="m-input" id="sph_img" onchange="phoneInputEdit(this);"  value="https://res.wailian1.cn/miniapp/links/20230627/8a1696162999cbbb25147d647a7c8d50.jpg"><div class="col-md-6 file-cotainer"><a href="javascript:;" class="file-border"><font>修改图片</font><input type="file" id="upload_sph_img" accept="image/*" onchange="jsUpload(\'sph_img\',100)"></a><img src="https://res.wailian1.cn/miniapp/links/20230627/8a1696162999cbbb25147d647a7c8d50.jpg" class="file-border-view" id="sph_img_show"></div>';
    } else if (links_lists.platfrom_type == 15) {
        $("#msgContentTitle").text("视频号直播参数配置:").show();
        htmls = '<div class="m-form-item"><label><b>*</b>视频号ID:<font>点击查看<a href="/admin/documents/documents_detail/75" target="_blank" class="text-primary">获取教程</a></font></label><div class="m-col-3 m-xs-12"><input type="text" class="m-input" id="sph_id" placeholder="请输入视频号ID" value="" onchange="phoneInputEdit(this)" maxlength="15"></div></div><label>小程序引导页:</label><input type="hidden" class="m-input" id="sph_img" onchange="phoneInputEdit(this);"  value="https://res.wailian1.cn/miniapp/links/20230627/6a2d86232d0ef578f3606c89d460a35b.jpg"><div class="col-md-6 file-cotainer"><a href="javascript:;" class="file-border"><font>修改图片</font><input type="file" id="upload_sph_img" accept="image/*" onchange="jsUpload(\'sph_img\',100)"></a><img src="https://res.wailian1.cn/miniapp/links/20230627/6a2d86232d0ef578f3606c89d460a35b.jpg" class="file-border-view" id="sph_img_show"></div>';
    } else if (links_lists.platfrom_type == 16) {
        $("#msgContentTitle").text("视频号视频参数配置:").show();
        htmls = '<div class="m-form-item"><label><b>*</b>视频号ID:<font>点击查看<a href="/admin/documents/documents_detail/75" target="_blank" class="text-primary">获取教程</a></font></label><div class="m-col-3 m-xs-12"><input type="text" class="m-input" id="sph_id" placeholder="请输入视频号ID" value="" onchange="phoneInputEdit(this)" maxlength="15"></div><div class="m-form-item"></div><label><b>*</b>视频ID:<font>点击查看<a href="/admin/documents/documents_detail/75" target="_blank" class="text-primary">获取教程</a></font></label><input type="text" class="m-input" id="sph_spid" placeholder="请输入视频ID" value="" onchange="phoneInputEdit(this)" maxlength="105"></div>';
    } else {
        $("#msgContentTitle").text("公众号文章配置:").show();
        htmls = '<div class="m-form-item"><label>微信公众号文章:<font>查看<a href="/admin/documents/documents_detail/60" class="text-primary" target="_blank">获取方法和注意事项</a>。</font></label><input type="text" class="m-input" id="msg_url" placeholder="请输入公众号文章链接" value="" onchange="phoneInputEdit(this)"></div>';
    }
    // 必须延时展示,否则无法弹出
    setTimeout("showTooltip();", 1000);
    $("#msgcontent").show().html(htmls);
}

$(function () {
    $("[data-toggle='tooltip']").tooltip();
});

function showMiniapp() {
    if ($.inArray(links_lists.platfrom_type, [7,10]) != -1) {
        $("#selectminiapps").hide();
        return;
    }
    var ismember = $("#ismember").val();
    var minapps = JSON.parse($("#minapps").val());
    // 可以选择的小程序
    var useableMiniapp = 0;
    var defaultMiniapp = false;
    if(minapps.length >= 1){
        $("#appid").html('');
        $.each(minapps,function(key,minapp){
            // 自有小程序
            if (minapp.scene == 1) {
                if (links_lists.platfrom_type == 4) {
                    $("#appid").append('<option value="'+minapp.appid+'">'+minapp.name+'</option>');
                    useableMiniapp += 1;
                    if (minapp.disable == 3 || links_lists.appid == "" || links_lists.appid == minapp.appid) {
                        links_lists.appid = minapp.appid;
                        $("#appid").val(minapp.appid);
                        defaultMiniapp = true;
                    }
                }
            } else {
                $("#appid").append('<option value="'+minapp.appid+'">'+minapp.name+'</option>');
                useableMiniapp += 1;
                // 有独家小程序并且未选择小程序
                if (minapp.disable == 3 && links_lists.appid == "") {
                    links_lists.appid = minapp.appid;
                    $("#appid").val(minapp.appid);
                    defaultMiniapp = true;
                } else{
                    // 有独家小程序并且小程序状态正常才选中
                    if (minapp.appid == links_lists.appid) {
                        $("#appid").val(links_lists.appid);
                        defaultMiniapp = true;
                    } else {
                        // 原来的小程序不存在了或者被删除了
                        if (key == (minapps.length-1)) {
                            if (!defaultMiniapp) {
                                links_lists.appid = minapp.appid;
                                $("#appid").val(minapp.appid);
                            }
                        }
                    }
                }
            }
        });
        // 最后还是没有独家小程序,则设置第一个(原来的小程序不存在了或者被删除了)
        if (!defaultMiniapp) {
            $.each(minapps,function(key,otherminapp){
                if ($.inArray(links_lists.platfrom_type, [1,2,3,6,8,9,11,12,13]) >= 0) {
                    if (otherminapp.scene == 2) {
                        links_lists.appid = otherminapp.appid;
                        $("#appid").val(otherminapp.appid);
                    }
                } else if (links_lists.platfrom_type == 4) {
                    if (otherminapp.scene == 1) {
                        links_lists.appid = otherminapp.appid;
                        $("#appid").val(otherminapp.appid);
                    }
                }
            });
        }
    }
    if(ismember){
        if(useableMiniapp < 1){
            // 没有可以使用的小程序
            if ($.inArray(links_lists.platfrom_type, [1,4,13,14,15,16]) != -1) {
                renderMiniappNotice();
            } else {
                $("#selectminiapps").hide();
                $("#minapp_add_notice").hide();
            }
        } else {
            $("#selectminiapps").show();
            $("#minapp_add_notice").hide();
        }
    }else{
        if(useableMiniapp < 1){
            // 没有可以使用的小程序
            if($.inArray(links_lists.platfrom_type, [4,14,15,16]) != -1) {
                renderMiniappNotice();
            } else {
                $("#selectminiapps").hide();
                $("#minapp_add_notice").hide();
            }
        } else {
            $("#selectminiapps").show();
            $("#minapp_add_notice").hide();
        }
    }
}

function renderMiniappNotice() {
    if (links_lists.platfrom_type == 1) {
        $("#appid").html('<option value="">请选择在天天外链上架的小程序</option>');
        $("#selectminiapps").show();
        $("#selectminiapps label font").html('前往 <a href="/admin/miniapps/miniapp_register" target="_blank">上架小程序</a> 或 <a href="/admin/miniapps/miniapp_lists" target="_blank">管理小程序</a>。');
        $("#minapp_add_notice").show().html('创建公众号文章链接类型需使用 <b>在天天外链上架</b> 的独家小程序；请前往 <a href="/admin/miniapps/miniapp_register" target="_blank">新上架小程序</a> 或 <a href="/miniapps/miniapp_lists" target="_blank">管理上架小程序</a> 后刷新本网页!');
    } else if(links_lists.platfrom_type == 13) {
        $("#appid").html('<option value="">请选择在天天外链上架的小程序</option>');
        $("#selectminiapps").show();
        $("#selectminiapps label font").html('前往 <a href="/admin/miniapps/miniapp_register" target="_blank">上架小程序</a> 或 <a href="/admin/miniapps/miniapp_lists" target="_blank">管理小程序</a>。');
        $("#minapp_add_notice").show().html('推广此类型链接需使用 <font class="text-warning" style="font-weight:500">在天天外链上架</font> 的独家小程序；请前往 <a href="/admin/miniapp/miniapp_bind" target="_blank">绑定企业小程序</a> 或 <a href="/admin/miniapp/miniapp_list" target="_blank">管理企业小程序</a> 后刷新本网页!');
    } else if(links_lists.platfrom_type == 14 || links_lists.platfrom_type == 15 || links_lists.platfrom_type == 16) {
        $("#appid").html('<option value="">请选择在天天外链上架的小程序</option>');
        $("#selectminiapps").show();
        $("#selectminiapps label font").html('前往 <a href="/admin/miniapps/miniapp_register" target="_blank">上架小程序</a> 或 <a href="/admin/miniapps/miniapp_lists" target="_blank">管理小程序</a>。');
        $("#minapp_add_notice").show().html('跳转视频号必须要求上架独家小程序；并且<b>视频号与小程序主体必须一致</b>，否则无法实现跳转。');
    } else if(links_lists.platfrom_type == 4) {
        if (links_lists.platfrom == 6) {
            $("#appid").html('<option value="">请选择微信小商店</option>');
            $("#selectminiapps").show();
            $("#selectminiapps label font").html('前往 <a href="/admin/miniapp/miniapp_bind" target="_blank">绑定新小商店</a> 或 <a href="/admin/miniapp/miniapp_list" target="_blank">管理微信小商店</a>。');
            $("#minapp_add_notice").hide();
        } else {
            $("#appid").html('<option value="">请选择微信小程序</option>');
            $("#selectminiapps").show();
            $("#selectminiapps label font").html('前往 <a href="/admin/miniapp/miniapp_bind" target="_blank">绑定新小程序</a> 或 <a href="/admin/miniapp/miniapp_list" target="_blank">管理小程序</a>。');
            $("#minapp_add_notice").hide();
        }
    } else {
        $("#selectminiapps").hide();
        $("#minapp_add_notice").hide();
    }
}

function changePlatfromType(platfromtype) {
    links_lists.platfrom_type = platfromtype;
    phonePreview();
    $("#qrcode_switch_type_row").hide();
    $("#qrcode_switch_upper_row").hide();
    $("#miniapp_style_row").hide();
    showMsg();
    if (links_lists.links_id == "") {
        if (links_lists.logo.search("miniapp/links") == -1) {
            if (links_lists.platfrom_type == 2 || links_lists.platfrom_type == 3){
                links_lists.logo = "https://res.wailian1.cn/miniapp/services_default.jpg";
            } else if (links_lists.platfrom_type == 6) {
                links_lists.logo = "https://res.wailian1.cn/miniapp/miniapp_default.jpg";
            } else {
                links_lists.logo = "http://nilife.oss-cn-beijing.aliyuncs.com/miniapp/wechat.png";
            }
        }
    }
    if (links_lists.platfrom_type == 1 || links_lists.platfrom_type == 13) {
        $("#wechat").val(links_lists.wechat);
        $("#msg_url").val(links_lists.msg_url);
    } else if (links_lists.platfrom_type == 14 || links_lists.platfrom_type == 15 || links_lists.platfrom_type == 16) {
        $("#sph_id").val(links_lists.sph_id);
        $("#sph_spid").val(links_lists.sph_spid);
        $("#sph_img").val(links_lists.sph_img);
        $("#sph_img_show").attr("src",links_lists.sph_img);
    } else if (links_lists.platfrom_type == 2 || links_lists.platfrom_type == 3) {
        $("#msg_logo").val(links_lists.logo);
        $("#msg_logo_show").attr("src",links_lists.logo);
        $("#button_show").val(links_lists.button_show);
        $("#button_text").val(links_lists.button_text);
        $("#service_notice").val(links_lists.service_notice);
        $("#service_image").val(links_lists.service_image);
        $("#service_image_show").attr("src",links_lists.service_image);
        if (links_lists.button_show == 1) {
            $("#button_text_row").show();
            $(".services-bottom").show();
        } else {
            $("#button_text_row").hide();
            $(".services-bottom").hide();
        }
    } else if (links_lists.platfrom_type == 4 || links_lists.platfrom_type == 5) {
        $("#msg_path").val(links_lists.path);
    }else if (links_lists.platfrom_type == 6) {
        $("#msg_logo").val(links_lists.logo);
        $("#msg_logo_show").attr("src",links_lists.logo);
        $("#msg_path").val(links_lists.miniapp.path);
        $("#msg_appid").val(links_lists.miniapp.appid);
        $("#msg_original_id").val(links_lists.miniapp.original_id);
        $("#button_show").val(links_lists.button_show);
        $("#button_text").val(links_lists.button_text);
        if (links_lists.button_show == 1) {
            $("#button_text_row").show();
            $(".services-bottom").show();
        } else {
            $("#button_text_row").hide();
            $(".services-bottom").hide();
        }
    }else if (links_lists.platfrom_type == 7) {
        $("#wechat").val(links_lists.wechat);
        $("#msg_logo_show").attr("src",links_lists.logo);
        $("#msg_logo").val(links_lists.logo);
        $("#msg_nike").val(links_lists.nike);
    } else if (links_lists.platfrom_type == 8 || links_lists.platfrom_type == 9) {
        $("#miniapp_style_row").show();
        $("#qrcode_switch_type_row").show();
        $("#wechat").val(links_lists.wechat);
        $("#msg_nike").val(links_lists.nike);
        $("#msg_describe").val(links_lists.describe);
        $("#msg_logo_show").attr("src",links_lists.logo);
        $("#msg_logo").val(links_lists.logo);
        $("#qrcode_notice").val(links_lists.qrcode_notice);

        $("#switch_lists li[data="+links_lists.qrcode_switch+"]").addClass("active");
        // $(":radio[name='qrcode_switch'][value='"+links_lists.qrcode_switch+"']").prop("checked", "checked");
        if (links_lists.qrcode_switch == 2) {
            $("#qrcode_switch_upper_row").hide();
        } else {
            $("#qrcode_switch_upper_row").show();
        }
        $("#limit_type_lists li[data="+links_lists.qrcode_upper+"]").addClass("active");
        $(":radio[name='qrcode_upper'][value='"+links_lists.qrcode_upper+"']").prop("checked", "checked");
        $("#qrcode_daily").val(links_lists.qrcode_daily);
        if (links_lists.qrcode_upper == 1) {
            $("#qrcode_qrcode_daily_row").hide();
        } else {
            $("#qrcode_qrcode_daily_row").show();
        }
        $(":radio[name='miniapp_style'][value='"+links_lists.miniapp_style+"']").prop("checked", "checked");
        if (links_lists.miniapp_style == 1) {
            $("#qrcode_setting").show();
            $("#qrcode_notice_row").show();
        } else {
            $("#qrcode_setting").hide();
            $("#qrcode_notice_row").hide();
        }
    } else if (links_lists.platfrom_type == 10) {
        $("#wechat").val(links_lists.wechat);
        $("#msg_nike").val(links_lists.nike);
        $("#msg_logo_show").attr("src",links_lists.logo);
        $("#msg_logo").val(links_lists.logo);
        $("#msg_url").val(links_lists.msg_url);
    } else if (links_lists.platfrom_type == 11 || links_lists.platfrom_type == 12) {
        $("#miniapp_style_row").show();
        $("#wechat").val(links_lists.wechat);
        $("#msg_nike").val(links_lists.nike);
        $("#msg_describe").val(links_lists.describe);
        $("#msg_logo_show").attr("src",links_lists.logo);
        $("#msg_logo").val(links_lists.logo);
        $("#qrcode_notice").val(links_lists.qrcode_notice);
        $(":radio[name='miniapp_style'][value='"+links_lists.miniapp_style+"']").prop("checked", "checked");
        if (links_lists.miniapp_style == 1) {
            $("#qrcode_setting").show();
            $("#qrcode_notice_row").show();
        } else {
            $("#qrcode_setting").hide();
            $("#qrcode_notice_row").hide();
        }
    } else {
        $("#msg_logo_show").attr("src",links_lists.logo);
        $("#msg_logo").val(links_lists.logo);
    }
}

function deleteStep(setpindex) {
    links_lists.services.splice(setpindex,1);
    showMsg();
}

function addStep(type) {
    if (type == 1) {
        links_lists.services.push({"type":1,"text":""});
    } else if(type == 2){
        links_lists.services.push({"type":2,"text":""});
    } else {
        links_lists.services.push({"type":3,"text":{"title":"","description":"","url":"","thumb_url":""}});
    }
    showMsg();
}

function changeStep(index,type) {
    var value = $("#msg_step"+index+"_"+type).val();
    if (type == "text") {
        links_lists.services[index].text = value;
    } else if (type == "img") {
        links_lists.services[index].text = value;
    } else if (type == "title") {
        links_lists.services[index].text.title = value;
    } else if (type == "description") {
        links_lists.services[index].text.description = value;
    } else if (type == "url") {
        links_lists.services[index].text.url = value;
    } else if (type == "thumb_url") {
        links_lists.services[index].text.thumb_url = value;
    } else {
        links_lists.services[index].text = value;
    }
    showMsg();
}

function submitAdd() {
    $("#alert_danger").hide();
    $("#alert_success").hide();
    if (links_lists.title.length< 3) {
        mviewToastr("error","请输入3字以上外链名称！");
        $("#title").focus();
        return;
    }
    var users_id = $("#users_id").val();
    var ismember = $("#ismember").val();
    if (links_lists.platfrom_type == 1) {
        if (ismember && links_lists.appid == "") {
            mviewToastr("error","请选择微信小程序！");
            return;
        }
        if (links_lists.msg_url == "") {
            mviewToastr("error","请输入公众号文章地址!");
            $("#msg_url").focus();
            return;
        }
        if (links_lists.msg_url.indexOf("https://mp.weixin.qq.com/s") == -1) {
            mviewToastr("error","请输入正确的公众号文章地址!");
            return;
        }
        if (links_lists.msg_url.indexOf("&tempkey=") != -1) {
            mviewToastr("error","请输入已发布的公众号文章链接!");
            return;
        }
    } else if (links_lists.platfrom_type == 13){
        if (links_lists.msg_url == "") {
            mviewToastr("error","请输入自有活码链接!");
            $("#msg_url").focus();
            return;
        }
        if (links_lists.msg_url.indexOf("qq.com/") != -1) {
            mviewToastr("error","请勿填写微信相关链接,直接使用二维码模式即可!");
            return;
        }
    } else if (links_lists.platfrom_type == 14 || links_lists.platfrom_type == 15 || links_lists.platfrom_type == 16){
        if (links_lists.sph_id.indexOf("sph") == -1) {
            mviewToastr("error","请输入正确的视频号ID!");
            return;
        }
        if (links_lists.platfrom_type == 16) {
            if (links_lists.sph_spid.indexOf("export/") == -1 && links_lists.sph_spid.indexOf("token/") == -1) {
                mviewToastr("error","请输入正确的视频ID!");
                return;
            }
        }
        if (links_lists.appid == "") {
            mviewToastr("error","请选择与视频号同主体的小程序!");
            return;
        }
    } else if (links_lists.platfrom_type == 2 || links_lists.platfrom_type == 3){
        mviewToastr("error","此模式已下架,无法继续使用!");
        return;
    } else if (links_lists.platfrom_type == 4){
        if (links_lists.appid == "") {
            mviewToastr("error","请选择微信小程序！");
            return;
        }
    } else if (links_lists.platfrom_type == 6){
    } else if (links_lists.platfrom_type == 7){
        if (links_lists.wechat == "") {
            mviewToastr("error","请输入微信号");
            return;
        }
        if (links_lists.nike == "") {
            mviewToastr("error","请输入微信昵称");
            return;
        }
    } else if (links_lists.platfrom_type == 8 || links_lists.platfrom_type == 9 || links_lists.platfrom_type == 11 || links_lists.platfrom_type == 12){
        if (links_lists.qrcodeLists.length <= 0) {
            mviewToastr("error","请上传微信二维码！");
            return;
        }
        if (links_lists.limit_type == 2 && links_lists.qrcode_daily == "") {
            mviewToastr("error","请输入默认每日上限数量!");
            return;
        }
        if (links_lists.miniapp_style == 1) {
            if (links_lists.nike == "") {
                if (links_lists.platfrom_type == 8 || links_lists.platfrom_type == 9) {
                    mviewToastr("error","默认模版样式必须填写微信昵称！");
                } else if (links_lists.platfrom_type == 11) {
                    mviewToastr("error","默认模版样式必须填写小程序名称！");
                } else {
                    mviewToastr("error","默认模版样式必须填写公众号名称！");
                }
                return;
            }
            if (links_lists.describe == "") {
                if (links_lists.platfrom_type == 8 || links_lists.platfrom_type == 9) {
                    mviewToastr("error","默认模版样式必须填写微信描述！");
                } else if (links_lists.platfrom_type == 11) {
                    mviewToastr("error","默认模版样式必须填写小程序描述！");
                } else {
                    mviewToastr("error","默认模版样式必须填写公众号描述！");
                }
                return;
            }
        }
    } else if (links_lists.platfrom_type == 10){
        if (links_lists.nike == "") {
            mviewToastr("error","请输入微信昵称");
            return;
        }
        if (links_lists.describe == "") {
            mviewToastr("error","请输入朋友圈提示");
            return;
        }
        if (links_lists.msg_url == "") {
            mviewToastr("error","请输入朋友圈链接");
            return;
        }
    }
    mviewToastr("load","创建中,请稍等...");
    var btnText = $("#addbutton").text();
    $("#addbutton").html("创建中,请稍等...").attr("onclick","");
    links_lists.users_id = users_id;
    $.ajax({
        "url": "/api/version/3/links/links_lists_add",
        "type": "POST",
        "data": links_lists,
        success: function(res){
            colsemviewToastr();
            if (res.status == "success") {
                $("#addbutton").html("创建成功,正在自动跳转...").addClass("m-btn-success");
                $("#alert_success").show().text(res.msg);
                $("#alert_danger").hide();
                setTimeout(function (){
                    window.location.href="/admin/links_lists/links_lists_detial/"+res.data.links_id;
                }, 3000);
            } else {
                $("#addbutton").html(btnText).attr("onclick","submitAdd()");
                if(res.code == 5005){
                    $("#alert_danger").show().html('当前账号无法使用公用小程序，请上架<a href="/admin/miniapps/register_mini_programs"> 独家小程序 </a>或者使用<a href="/admin/safe/safetip?type=1"> 【摩尔营销通】 </a>进行推广，具体原因查看天天外链公用小程序说明。');
                }else{
                   $("#alert_danger").show().text(res.msg); 
                }
                $("#alert_success").hide();
                if (res.code == 1010) {
                    setTimeout(function (){
                        window.location.href="/admin/login";
                    }, 3000);
                }
            }
        },
        error: function(err){
            $("#addbutton").html(btnText).attr("onclick","submitAdd()");
            mviewToastr("error","请求失败,请稍后重试！");
            $("#alert_success").hide();
        }
    });
}

function submitUpdate() {
    $("#alert_danger").hide();
    $("#alert_success").hide();
    if (links_lists.title.length< 3) {
        mviewToastr("error","请输入3字以上外链名称！");
        $("#title").focus();
        return;
    }
    var users_id = $("#users_id").val();
    var ismember = $("#ismember").val();
    if (links_lists.platfrom_type == 1) {
        if (ismember && links_lists.appid == "") {
            mviewToastr("error","请选择微信小程序！");
            return;
        }
        if (links_lists.msg_url == "") {
            mviewToastr("error","请输入公众号文章地址/网页地址");
            $("#msg_url").focus();
            return;
        }
    } else if (links_lists.platfrom_type == 2 || links_lists.platfrom_type == 3){
    } else if (links_lists.platfrom_type == 4){
        if (links_lists.appid == "") {
            mviewToastr("error","请选择微信小程序！");
            return;
        }
    } else if (links_lists.platfrom_type == 6){
    } else if (links_lists.platfrom_type == 7){
        if (links_lists.wechat == "") {
            mviewToastr("error","请输入微信号");
            return;
        }
        if (links_lists.nike == "") {
            mviewToastr("error","请输入微信昵称");
            return;
        }
    } else if (links_lists.platfrom_type == 8 || links_lists.platfrom_type == 9 || links_lists.platfrom_type == 11 || links_lists.platfrom_type == 12){
        if (links_lists.qrcodeLists.length <= 0) {
            mviewToastr("error","请上传微信二维码！");
            return;
        }
        if (links_lists.miniapp_style == 1) {
            if (links_lists.nike == "") {
                if (links_lists.platfrom_type == 8 || links_lists.platfrom_type == 9) {
                    mviewToastr("error","默认风格必须填写微信昵称！");
                } else if (links_lists.platfrom_type == 11) {
                    mviewToastr("error","默认风格必须填写小程序名称！");
                } else {
                    mviewToastr("error","默认风格必须填写公众号名称！");
                }
                return;
            }
            if (links_lists.describe == "") {
                if (links_lists.platfrom_type == 8 || links_lists.platfrom_type == 9) {
                    mviewToastr("error","默认风格必须填写微信描述！");
                } else if (links_lists.platfrom_type == 11) {
                    mviewToastr("error","默认风格必须填写小程序描述！");
                } else {
                    mviewToastr("error","默认风格必须填写公众号描述！");
                }
                return;
            }
        }
    } else if (links_lists.platfrom_type == 10){
        if (links_lists.nike == "") {
            mviewToastr("error","请输入微信昵称");
            return;
        }
        if (links_lists.describe == "") {
            mviewToastr("error","请输入朋友圈提示");
            return;
        }
        if (links_lists.msg_url == "") {
            mviewToastr("error","请输入朋友圈链接");
            return;
        }
    }
    $("#updatebutton").html("更新中,请稍等...").attr("onclick","");
    links_lists.users_id = users_id;
    $.ajax({
        "url": "/api/version/3/links/links_lists_update",
        "type": "POST",
        "data": links_lists,
        success: function(res){
            if (res.status == "success") {
                $("#updatebutton").html("链接更新成功").addClass("m-btn-success");
                $("#alert_success").show().text(res.msg);
                $("#alert_danger").hide();
                setTimeout(function (){
                    window.location.href="/admin/links_lists/links_lists_detial/"+links_lists.links_id;
                }, 3000);
            } else {
                $("#updatebutton").html("更新外链").attr("onclick","submitUpdate()");
                $("#alert_danger").show().text(res.msg);
                $("#alert_success").hide();
                if (res.code == 1010) {
                    setTimeout(function (){
                        window.location.href="/admin/login";
                    }, 3000);
                }
            }
        },
        error: function(err){
            $("#updatebutton").html("更新外链").attr("onclick","submitUpdate()");
            mviewToastr("error","请求失败,请稍后重试！");
            $("#alert_success").hide();
        }
    });
}

function showTooltip() {
    $("[data-toggle='tooltip']").tooltip();
}

function gotoArticle(id) {
    window.open("/admin/documents/documents_detail/"+id);
}

function phoneInputEdit(object) {
    var id = object.id;
    var value = object.value;
    if (id == "msg_nike") {
        if (links_lists.platfrom_type == 7 || links_lists.platfrom_type == 10) {
            $(".phone-image-copy p").text(value);
        } else {
            $(".phone-default-header-right h3").text(value);
        }
        links_lists.nike = value;
    } else if (id == "msg_describe") {
        $(".phone-default-header-right h5").text(value);
        links_lists.describe = value;
    } else if (id == "msg_logo") {
        setTimeout(function(){
            var image = $("#msg_logo").val();
            if (links_lists.platfrom_type == 7 || links_lists.platfrom_type == 10) {
                $(".phone-image-copy img").attr("src",image);
            } else {
                $("#phone-default-header-img").attr("src",image);
            }
            links_lists.logo = image;
        },100);
    } else if (id == "miniapp_style") {
        var miniapp_style = $("input[name='miniapp_style']:checked").val();
        links_lists.miniapp_style = miniapp_style;
        $(".phone-default-cotain").hide();
        $(".phone-body-full").hide();
        if (miniapp_style == 1) {
            $("#qrcode_setting").show();
            $("#qrcode_notice_row").show();
            $(".phone-default-cotain").show();
        } else {
            $("#qrcode_setting").hide();
            $("#qrcode_notice_row").hide();
            $(".phone-body-full").show();
            if (links_lists.platfrom == 1 && links_lists.platfrom_type == 12) {
                $(".phone-body-full img").attr("src","https://res.wailian1.cn/miniapp/links/20230627/7f07440a1fe9489631219faeea2b48c0.jpg");
            } else if (links_lists.platfrom == 2 && links_lists.platfrom_type == 11) {
                $(".phone-body-full img").attr("src","http://ttwls.oss-cn-beijing.aliyuncs.com/assets/demos/qt_xcx.jpg");
            } else if (links_lists.platfrom == 3 && links_lists.platfrom_type == 8) {
                $(".phone-body-full img").attr("src","https://res.wailian1.cn/miniapp/links/20230627/7f07440a1fe9489631219faeea2b48c0.jpg");
            } else if (links_lists.platfrom == 4 && links_lists.platfrom_type == 8) {
                $(".phone-body-full img").attr("src","https://res.wailian1.cn/miniapp/links/20230627/7f07440a1fe9489631219faeea2b48c0.jpg");
            } else if (links_lists.platfrom == 6 && links_lists.platfrom_type == 9) {
                $(".phone-body-full img").attr("src","http://ttwls.oss-cn-beijing.aliyuncs.com/assets/demos/qt_wxq.jpg");
            } else if (links_lists.platfrom == 11 && links_lists.platfrom_type == 11) {
                $(".phone-body-full img").attr("src","http://ttwls.oss-cn-beijing.aliyuncs.com/assets/demos/qt_xcx.jpg");
            } else if (links_lists.platfrom == 6 && links_lists.platfrom_type == 11) {
                $(".phone-body-full img").attr("src","http://ttwls.oss-cn-beijing.aliyuncs.com/assets/demos/qt_xcx.jpg");
            } else if (links_lists.platfrom == 5 && links_lists.platfrom_type == 9) {
                $(".phone-body-full img").attr("src","http://ttwls.oss-cn-beijing.aliyuncs.com/assets/demos/qt_wxq.jpg");
            } else {
                console.log(links_lists.platfrom);
                console.log(links_lists.platfrom_type);
            }
        }
    } else if (id == "describe") {
        if (id == "describe") {
            $(".services-bottom").text(value);
        }
        links_lists.describe = value;
    } else if (id == "qrcode_notice") {
        $(".phone-default-footer").text(value);
        links_lists.qrcode_notice = value;
    } else if (id == "qrcode_daily") {
        links_lists.qrcode_daily = $("#qrcode_daily").val();
    } else if (id == "image") {
        setTimeout(function(){
            var image = $("#image").val();
            $(".phone-image-services img").attr("src",image);
            links_lists.image = image;
        },100);
    } else if (id == "button_show") {
        links_lists.button_show = value;
        if (value == 1) {
            $("#button_text_row").show();
            $(".services-bottom").show();
        } else {
            $("#button_text_row").hide();
            $(".services-bottom").hide();
        }
    } else if (id == "service_notice") {
        links_lists.service_notice = value;
        links_lists.service_image = "https://res.wailian1.cn/miniapp/services/services"+value+".jpg";
        $("#service_image").val(links_lists.service_image);
        $("#service_image_show").attr("src",links_lists.service_image);
    } else if (id == "msg_original_id" || id == "msg_appid" || id == "msg_path") {
        if (links_lists.platfrom_type == 6) {
            if (id == "msg_original_id") {
                links_lists.miniapp.original_id = value;
            } else if (id == "msg_appid") {
                links_lists.miniapp.appid = value;
            } else if (id == "msg_path") {
                links_lists.miniapp.path = value;
            } else {

            }
        } else {
            links_lists.path = value;
        }
    } else if (id == "qrcode_switch" || id == "qrcode_upper") {
        qrcode_info = $("input[name='"+id+"']:checked").val();
        if (id == "qrcode_switch") {
            if (qrcode_info == 2) {
                $("#qrcode_switch_upper_row").hide();
            } else {
                $("#qrcode_switch_upper_row").show();
            }
        }
        if (id == "qrcode_upper") {
            if (qrcode_info == 1) {
                $("#qrcode_qrcode_daily_row").hide();
            } else {
                $("#qrcode_qrcode_daily_row").show();
            }
        }
        links_lists[id] = qrcode_info;
    } else if (id == "sph_id") {
        links_lists.sph_id = $("#sph_id").val();
    } else if (id == "sph_spid") {
        links_lists.sph_spid = $("#sph_spid").val();
    } else if (id == "sph_img") {
        setTimeout(function(){
            var sph_img = $("#sph_img").val();
            links_lists.sph_img = sph_img;
            $(".phone-body-full img").attr("src",sph_img);
        },100);
    } else {
        links_lists[id] = $("#"+id).val();
    }
}

function phonePreview() {
    $(".phone-default-cotain").hide();
    $(".phone-body-full").hide();
    $(".phone-image-services").hide();
    $(".phone-image-copy").hide();
    // console.log("phonePreview---");
    // console.log(links_lists);
    // console.log("phonePreview---");
    if (links_lists.platfrom_type == 1) {
        $(".phone-body-full").show();
        $(".phone-body-full img").attr("src","http://ttwls.oss-cn-beijing.aliyuncs.com/assets/demos/zd_gzh.jpg");
    } else if(links_lists.platfrom_type == 2 || links_lists.platfrom_type == 3) {
        // 客服模式
        $(".phone-image-services").show();
        $(".phone-image-services img").attr("src","https://res.wailian1.cn/miniapp/services_default.jpg");
        $(".services-bottom").text("点击联系客服")
    } else if(links_lists.platfrom_type == 4) {
        $(".phone-body-full").show();
        $(".phone-body-full img").attr("src","http://ttwls.oss-cn-beijing.aliyuncs.com/assets/demos/zd_xcx.jpg");
    } else if(links_lists.platfrom_type == 7) {
        // 复制搜索
        $(".phone-image-copy").show();
        $(".phone-image-copy p").text("天天外链公众号");
        $(".phone-image-copy-addbutton").text("复制并打开微信");
    } else if(links_lists.platfrom_type == 8) {
        if (links_lists.miniapp_style == 1) {
            $(".phone-default-cotain").show();
            $(".phone-default-header-right h3").text(links_lists.nike == "" ? "天天外链客服" : links_lists.nike);
            $(".phone-default-header-right h5").text(links_lists.describe == "" ? "添加老师免费领取课程" : links_lists.describe);
            $(".phone-default-footer").text(links_lists.qrcode_notice);
            $("#phone-default-header-img").attr("src",links_lists.logo == "" ? "http://nilife.oss-cn-beijing.aliyuncs.com/miniapp/wechat.png" : links_lists.logo);
            if (links_lists.qrcodeLists.length > 0) {
                $(".phone-default-qrcode").attr("src",links_lists.qrcodeLists[0].img_url);
            } else {
                if (links_lists.platfrom == 3) {
                    $(".phone-default-qrcode").attr("src","http://ttwls.oss-cn-beijing.aliyuncs.com/assets/demos/gr.jpg");
                } else {
                    $(".phone-default-qrcode").attr("src","http://ttwls.oss-cn-beijing.aliyuncs.com/assets/demos/qywx.jpg");
                }
            }
        } else {
            $(".phone-body-full").show();
            if (links_lists.qrcodeLists.length > 0) {
                $(".phone-body-full img").attr("src",links_lists.qrcodeLists[0].img_url);
            } else {
                if (links_lists.platfrom == 3) {
                    $(".phone-body-full img").attr("src","https://res.wailian1.cn/miniapp/links/20230627/7f07440a1fe9489631219faeea2b48c0.jpg");
                } else {
                    $(".phone-body-full img").attr("src","https://res.wailian1.cn/miniapp/links/20230627/7f07440a1fe9489631219faeea2b48c0.jpg");
                }
            }
        }
    } else if(links_lists.platfrom_type == 9) {
        if (links_lists.miniapp_style == 1) {
            $(".phone-default-cotain").show();
            $(".phone-default-header-right h3").text(links_lists.nike == "" ? "XX活动群" : links_lists.nike);
            $(".phone-default-header-right h5").text(links_lists.describe == "" ? "进群领取优惠券" : links_lists.describe);
            $(".phone-default-footer").text(links_lists.qrcode_notice);
            $("#phone-default-header-img").attr("src",links_lists.logo == "" ? "http://ttwls.oss-cn-beijing.aliyuncs.com/assets/demos/gzh.jpg" : links_lists.logo);
            if (links_lists.qrcodeLists.length > 0) {
                $(".phone-default-qrcode").attr("src",links_lists.qrcodeLists[0].img_url);
            } else {
                $(".phone-default-qrcode").attr("src","http://ttwls.oss-cn-beijing.aliyuncs.com/assets/demos/gr.jpg");
            }
        } else {
            $(".phone-body-full").show();
            if (links_lists.qrcodeLists.length > 0) {
                $(".phone-body-full img").attr("src",links_lists.qrcodeLists[0].img_url);
            } else {
                $(".phone-body-full img").attr("src","https://res.wailian1.cn/miniapp/links/20230627/7f07440a1fe9489631219faeea2b48c0.jpg");
            }
        }
    } else if(links_lists.platfrom_type == 10) {
        // 朋友圈模式
        $(".phone-image-copy").show();
        $(".phone-image-copy p").text("天天外链公众号");
        $(".phone-image-copy-addbutton").text("点击前往微信");
    } else if(links_lists.platfrom_type == 12) {
        if (links_lists.miniapp_style == 1) {
            $(".phone-default-cotain").show();
            $(".phone-default-header-right h3").text(links_lists.nike == "" ? "天天外链公众号" : links_lists.nike);
            $(".phone-default-header-right h5").text(links_lists.describe == "" ? "关注公众号免费体验" : links_lists.describe);
            $(".phone-default-footer").text(links_lists.qrcode_notice);
            $("#phone-default-header-img").attr("src",links_lists.logo == "" ? "http://ttwls.oss-cn-beijing.aliyuncs.com/assets/demos/gzh.jpg" : links_lists.logo);
            if (links_lists.qrcodeLists.length > 0) {
                $(".phone-default-qrcode").attr("src",links_lists.qrcodeLists[0].img_url);
            } else {
                $(".phone-default-qrcode").attr("src","http://ttwls.oss-cn-beijing.aliyuncs.com/assets/demos/gzh.jpg");
            }
        } else {
            $(".phone-body-full").show();
            if (links_lists.qrcodeLists.length > 0) {
                $(".phone-body-full img").attr("src",links_lists.qrcodeLists[0].img_url);
            } else {
                $(".phone-body-full img").attr("src","https://res.wailian1.cn/miniapp/links/20230627/7f07440a1fe9489631219faeea2b48c0.jpg");
            }
        }
    } else if(links_lists.platfrom_type == 11) {        
        if (links_lists.miniapp_style == 1) {
            $(".phone-default-cotain").show();
            $(".phone-default-header-right h3").text(links_lists.nike == "" ? "XXX品牌旗舰店" : links_lists.nike);
            $(".phone-default-header-right h5").text(links_lists.describe == "" ? "长按小程序码前往小程序" : links_lists.describe);
            $(".phone-default-footer").text(links_lists.qrcode_notice);
            $("#phone-default-header-img").attr("src",links_lists.logo == "" ? "http://ttwls.oss-cn-beijing.aliyuncs.com/assets/demos/gzh.jpg" : links_lists.logo);
            if (links_lists.qrcodeLists.length > 0) {
                $(".phone-default-qrcode").attr("src",links_lists.qrcodeLists[0].img_url);
            } else {
                $(".phone-default-qrcode").attr("src","http://ttwls.oss-cn-beijing.aliyuncs.com/assets/demos/xcx.jpg");
            }
        } else {
            $(".phone-body-full").show();
            if (links_lists.qrcodeLists.length > 0) {
                $(".phone-body-full img").attr("src",links_lists.qrcodeLists[0].img_url);
            } else {
                $(".phone-body-full img").attr("src","http://ttwls.oss-cn-beijing.aliyuncs.com/assets/demos/qt_xcx.jpg");
            }
        }
    } else if(links_lists.platfrom_type == 6) {
        // 三方小程序
        $(".phone-image-services").show();
        $(".phone-image-services img").attr("src","https://res.wailian1.cn/miniapp/miniapp_default.jpg");
    } else if(links_lists.platfrom_type == 5) {
        $(".phone-body-full").show();
        $(".phone-body-full img").attr("src","http://ttwls.oss-cn-beijing.aliyuncs.com/assets/demos/zd_xcx.jpg");
    } else if(links_lists.platfrom_type == 13) {
        $(".phone-body-full").show();
        $(".phone-body-full img").attr("src","http://ttwls.oss-cn-beijing.aliyuncs.com/assets/demos/zd_gzh.jpg");
    } else if(links_lists.platfrom_type == 14 || links_lists.platfrom_type == 15 || links_lists.platfrom_type == 16) {
        $(".phone-body-full").show();
        $(".phone-body-full img").attr("src",links_lists.sph_img);
    } else {
        alert(links_lists.platfrom_type);
    }
}

function updateQrcodesImages(qrcodes_id) {
    $("#qrcodeModal").modal('toggle');

    $.each(links_lists.qrcodeLists,function(key,qrcodeList){
        if (qrcodeList.qrcodes_id == qrcodes_id) {
            $("#qrcodes_id").val(qrcodeList.qrcodes_id);
            $("#qrcode_show").attr("src",qrcodeList.img_url);
            $("#qrcode").val(qrcodeList.img_url);
            $("#qrcodes_name").val(qrcodeList.name);
            $("#expiration_time").val(qrcodeList.expiration_time);
            $("#rate").val(qrcodeList.rate);
            $("#count_limit").val(qrcodeList.count_limit);
        }
    });
}

function updateQrcodesImagesSubmit() {
    var qrcodes_id = $("#qrcodes_id").val();
    $.each(links_lists.qrcodeLists,function(key,qrcodeList){
        if (qrcodeList.qrcodes_id == qrcodes_id) {
            qrcodeList.img_url = $("#qrcode_show").attr("src");
            qrcodeList.name = $("#qrcodes_name").val();
            qrcodeList.expiration_time = $("#expiration_time").val();
            qrcodeList.rate = $("#rate").val();
            qrcodeList.count_limit = $("#count_limit").val();
        }
    });
    $("#qrcodeModal").modal('toggle');
}

function renderQrcodes(qrcode_menu) {
    if (typeof(qrcode_menu) == "undefined") qrcode_menu = "msg_qrcodes";
    $("#"+qrcode_menu+"_lists").html("");
    $.each(links_lists.qrcodeLists,function(key,qrcodeList){
        if ($.inArray(links_lists.platfrom_type, [8,9]) == -1) {
            $("#"+qrcode_menu+"_lists").prepend('<div id="'+qrcodeList.qrcodes_id+'"><img src="'+qrcodeList.img_url+'" class="file-border-view-lists"><i class="file-cotainer-icon iconfont icon-guanbi" onclick=\'deleteImages("'+qrcodeList.qrcodes_id+'");\'></i></div>');
        } else {
            $("#"+qrcode_menu+"_lists").prepend('<div id="'+qrcodeList.qrcodes_id+'"><img src="'+qrcodeList.img_url+'" class="file-border-view-lists"><i class="file-cotainer-info iconfont icon-gengduo" onclick=\'updateQrcodesImages("'+qrcodeList.qrcodes_id+'");\'></i></div>');
        }
    });
}

function deleteImages(qrcodes_id) {
    if (typeof(qrcodes_id) == "undefined") {
        qrcodes_id = $("#qrcodes_id").val();
        $("#qrcodeModal").modal('toggle');
    }
    var qrcodeLists = [];
    $.each(links_lists.qrcodeLists,function(key,qrcodeList){
        if (qrcodeList.qrcodes_id != qrcodes_id) {
            qrcodeLists.push(qrcodeList);
        }
    });
    links_lists.qrcodeLists = qrcodeLists;
    renderQrcodes();
}

function addTopNotice(status) {
    if (status == "close") {
        var weeks = moment().add(1, "weeks").unix();
        localStorage.setItem("addnotice",weeks);
        $("#addnotice").fadeOut();
    } else {
        var nowtime = moment().unix();
        var oldtime = localStorage.getItem("addnotice") || 1;
        if (oldtime > nowtime) {
            $("#addnotice").hide();
        } else {
            $("#addnotice").show();
        }
    }
}